package com.webkitlib.util;

import java.util.Calendar;

import android.view.View;
import android.view.View.OnClickListener;
/**
 * 
 * 点击事件做延迟，配合涟漪使用
 * 
 * @author 韩伟光
 * @version 1.0
 * @since 2016-1-29
 */
public abstract class KNoDoubleClickListener implements OnClickListener {
    public static final int MIN_CLICK_DELAY_TIME = 1200; // 延时的时间
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        /* 判断上次点击和这个点击时间要大于延时时间，这样就不会两次进入同一个界面了 */
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onNoDoubleClick(v);
        }
    }

    public abstract void onNoDoubleClick(View v);
}
